package ar.com.ford.it.fullEconomics.logic;

import java.util.Collection;
import ar.com.ford.it.fullEconomics.FullEconomicsPrs;
import ar.com.ford.it.fullEconomics.exception.FullEconomicsException;
import ar.com.ford.it.fullEconomics.persistence.dao.Dao;
import ar.com.ford.it.fullEconomics.persistence.dao.VehiclelinDao;
import ar.com.ford.it.fullEconomics.persistence.dto.Ncas012VehicleVw;
import com.ford.it.logging.ILogger;
import com.ford.it.logging.Level;
import com.ford.it.logging.LogFactory;
import com.ford.it.persistence.PersistenceException;

public class VehiclelinLogic extends Dao {
    private static final String CLASS_NAME = VehiclelinLogic.class.getName();
    private static final ILogger log = LogFactory.getInstance().getLogger(
            CLASS_NAME);

    /**
     * 
     * @return
     * @throws FullEconomicsException
     */
    public Collection<Ncas012VehicleVw> findAllVehiclelin()
            throws FullEconomicsException {

        String METHOD_NAME = "findAll";
        log.entering(CLASS_NAME, METHOD_NAME);

        Collection<Ncas012VehicleVw> res = null;

        try {
            res = this.findAll(new Ncas012VehicleVw(), null, null);
        } catch (PersistenceException e) {
            log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
                    "Find all Economic Value Exception", e);
            throw new FullEconomicsException(e,
                    FullEconomicsPrs.MessageErrors.EconomicValue.FINDALL);
        } catch (Exception excep)
        {
        	log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
                    "Find all Economic Value Exception", excep.getMessage());
        }

        log.exiting(CLASS_NAME, METHOD_NAME);
        return res;
    }

    /**
     * 
     * @param veIn
     * @return
     * @throws FullEconomicsException
     */
    public Ncas012VehicleVw getVehiclelinUpdateByPk(Ncas012VehicleVw veIn)
            throws FullEconomicsException {

        String METHOD_NAME = "getVehiclelinUpdateByPk";
        log.entering(CLASS_NAME, METHOD_NAME);

        Ncas012VehicleVw res = null;
        VehiclelinDao dao = new VehiclelinDao();
        try {
            res = dao.getVehiclelinUpdateByPk(veIn);
        } catch (PersistenceException e) {
            log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
                    "Find all Economic Value Exception", e);
            throw new FullEconomicsException(e,
                    FullEconomicsPrs.MessageErrors.EconomicValue.FINDALL);
        }

        log.exiting(CLASS_NAME, METHOD_NAME);
        return res;
    }

    /**
     * Busca el Vehicle Line pasado por parametro
     * 
     * @param pk
     * @return
     * @throws FullEconomicsException
     */
    public Ncas012VehicleVw findVehicleLineByPk(Ncas012VehicleVw pk)
            throws FullEconomicsException {
        String METHOD_NAME = "findVehicleLineByPk";
        log.entering(CLASS_NAME, METHOD_NAME);

        VehiclelinDao dao = new VehiclelinDao();

        try {
            pk = (Ncas012VehicleVw) dao.getObjById(pk);
        } catch (PersistenceException e) {
            log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
                    "Find Vehicle Line By PK Exception", e);
            throw new FullEconomicsException(e,
                    FullEconomicsPrs.MessageErrors.VehicleLine.FINDBYPK);
        }

        log.exiting(CLASS_NAME, METHOD_NAME);
        return pk;
    }

}
